package cn.swu.lzr.collection;

import com.mysql.cj.Session;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
import java.util.List;
import java.util.ArrayList;

public class DeleteCollection extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        Integer id = Integer.valueOf(request.getParameter("eventId"));

        HttpSession session = request.getSession();
        ArrayList ItemList = (ArrayList) session.getAttribute("Collection");

        ItemList.remove(Integer.valueOf(id));

        session.setAttribute("Collection",ItemList);

        response.sendRedirect("/java-design/NewCollection.html");
    }

}
